# Contributor: Kaarle Ritvanen <kunkku@alpinelinux.org>
# Maintainer:
pkgname=lua-inet
_rockname=${pkgname#lua-}
pkgver=0.2.0
pkgrel=1
_gittag=${pkgname}_$pkgver
pkgdesc="An IP address mangling library for Lua"
url="https://git.2e8.dk/lua-inet/"
arch="noarch"
license="LGPL-3.0-only"
depends="lua-lpeg"
checkdepends="lua5.2 lua5.3 luacheck"
source="$pkgname-$pkgver.tar.gz::https://git.2e8.dk/lua-inet//snapshot/$_gittag.tar.gz
	luacheck.patch
	fix-inet-check-error.patch"
builddir="$srcdir/$_gittag"

_luaversions="5.2 5.3 5.4"
for _v in $_luaversions; do
	provides="$provides lua$_v-$_rockname=$pkgver-r$pkgrel"
done

check() {
	make test
}

package() {
	local dir=$pkgdir/usr/share/lua/common
	local rockdir=$pkgdir/usr/lib/luarocks/rocks-common/$_rockname/$pkgver-1
	mkdir -p "$dir" "$rockdir"
	cp -r lua/inet "$dir"
	echo 'rock_manifest = {}' > "$rockdir"/rock_manifest
}

sha512sums="
9717926ce959fb06de89c6159bdd5abbe0fe837e22a192df165da8633e78b53ddc84c6a2156e8a5c603222011a93c15cfe00eeae867189ba94e32df21b4cf26a  lua-inet-0.2.0.tar.gz
3450320f865b77bfd41de7d6cf99550fa1b84bb6c61816c3175108b48b251036615fb1d48f1f5c8b90eab8d408839d278c5c11a3b68d610a21ad2393a3f5569a  luacheck.patch
edaf3ef1862bc12fab7e5872c8831fd08a479021f1dd03d8498bc9c2f381df822bd3bb0b0829faaf10a41bc8956206887485a59590bed164a0dc12e4570e7e3d  fix-inet-check-error.patch
"
